"var GumMessageDispatcher, GumMessageRecvOperation, recv, send, _dispatcher;"
"var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };"
"GumMessageDispatcher = (function() {"
  "function GumMessageDispatcher() {"
    "this.handleMessage = __bind(this.handleMessage, this);;    this.messages = [];"
    "this.operations = {};"
    "_setIncomingMessageCallback(this.handleMessage);"
  "}"
  "GumMessageDispatcher.prototype.registerCallback = function(type, callback) {"
    "var op;"
    "op = new GumMessageRecvOperation(callback);"
    "this.operations[type] = op;"
    "this.dispatchMessages();"
    "return op;"
  "};"
  "GumMessageDispatcher.prototype.handleMessage = function(rawMessage) {"
    "this.messages.push(JSON.parse(rawMessage));"
    "return this.dispatchMessages();"
  "};"
  "GumMessageDispatcher.prototype.dispatchMessages = function() {"
    "var message, pending, _i, _len;"
    "pending = this.messages.splice(0, this.messages.length);"
    "for (_i = 0, _len = pending.length; _i < _len; _i++) {"
      "message = pending[_i];"
      "this.dispatch(message);"
    "}"
  "};"
  "GumMessageDispatcher.prototype.dispatch = function(message) {"
    "var handlerType, operation;"
    "if (this.operations[message.type]) {"
      "handlerType = message.type;"
    "} else if (this.operations['*']) {"
      "handlerType = '*';"
    "} else {"
      "this.messages.push(message);"
      "return;"
    "}"
    "operation = this.operations[handlerType];"
    "delete this.operations[handlerType];"
    "operation._complete(message);"
  "};"
  "return GumMessageDispatcher;"
"})();"
"GumMessageRecvOperation = (function() {"
  "function GumMessageRecvOperation(callback) {"
    "this.callback = callback;"
    "this.completed = false;"
  "}"
  "GumMessageRecvOperation.prototype.wait = function() {"
    "var _results;"
    "_results = [];"
    "while (!this.completed) {"
      "_results.push(_waitForEvent());"
    "}"
    "return _results;"
  "};"
  "GumMessageRecvOperation.prototype._complete = function(message) {"
    "this.callback(message);"
    "return this.completed = true;"
  "};"
  "return GumMessageRecvOperation;"
"})();"
"_dispatcher = new GumMessageDispatcher();"
"send = function(payload) {"
  "var message;"
  "message = {"
    "type: 'send',"
    "payload: payload"
  "};"
  "return _send(JSON.stringify(message));"
"};"
"recv = function() {"
  "var callback, type;"
  "if (arguments.length === 1) {"
    "type = '*';"
    "callback = arguments[0];"
  "} else {"
    "type = arguments[0];"
    "callback = arguments[1];"
  "}"
  "return _dispatcher.registerCallback(type, callback);"
"};"
